/***************************************************************************
 创建者: 华磊
 开始时间: 2019.9.20
 copyright: (C) 华友高科
 修改说明: (每次有修改就添加一条，带有 修改人，修改时间，修改描述)
 example (1) 姓名 2019.9.20 类的具体实现代码编写

 ***************************************************************************
 *  @file x.h
 *  功能:
 *
 *
 ***************************************************************************/

#ifndef PROTOCOLCODEING_H
#define PROTOCOLCODEING_H
#include <QString>
#include "../CommunicateDelegate/gSoapFoundation/soapStub.h"
//struct VehiclePosition {
//      public:
//        /** Required element 'x' of XSD type 'xsd:double' */
//        double x;
//        /** Required element 'y' of XSD type 'xsd:double' */
//        double y;
//        /** Required element 'rotate' of XSD type 'xsd:double' */
//        double rotate;
//};
enum E_AGV_STATE
{
    E_AGV_STATE_IDILE=0,
    E_AGV_STATE_MOVING=1,
    E_AGV_STATE_LOSE_POSITION=2,
    E_AGV_STATE_LASER_CEASE=3,
    E_AGV_STATE_LASER_STOP=4,
    E_AGV_STATE_INFRARED_STOP=5,
    E_AGV_STATE_ULTRASONIC_STOP=6,
    E_AGV_STATE_CHARGING=7,
    E_AGV_STATE_CEASE=8,
    E_AGV_STATE_EMERGENCE_STOP=9,
    E_AGV_STATE_COMMAND_READY=10,
    E_AGV_STATE_ULTRASONIC_CEASE=100,
    E_AGV_STATE_INTERNAL_ERROR=101,

};
struct FleetAgvBasicInfo
{
    VehiclePosition position;
    E_AGV_STATE state;
    bool isLoaded;
    double batteryLeftLightModeRatio;
    double lineSpeed;
    double rotateSpeed;
    int errorId;
    int warnId;
    int noticeId;
    double targetPositionLeft_line;
    double targetPositionLeft_angle;
    int heartBeat;
    int passedStationId;//最后经过的站点id，负数代表未知
    int nextStationId;//下一个站点id，负数代表未知
    int currentStationId;//当前所在的站点id，负数表示不在站点
    int passedPathId;//最后经过的路径id，负数代表未知
    int nextPathId;//下一个路径id，负数代表未知
    int currentPathId;//当前所处的路径id，负数表示不在任何路径
    QString currentMap;
    int mapVersion;
    long long diStatus;
    long long doStatus;
    int liftStatus;
    int rollerStatus;
    int floorId;
    int agvMode;
    int borderId;
    int barrierMode;
    int diTrigCount;

};

struct ArmInfo
{
    QString status;
    int currentToolCoorIndex;
    int currentUserCoorIndex;
    double x;
    double y;
    double z;
    double w;
    double p;
    double r;
    int axisCount;
    QVector<double> jointsPosition;
};

//请求或回应格式：0x0a(换行符\n）+headers（字符表示）+payload（字符表示）+0x0d（回车符\r）
class ProtocolCodeing
{
public:
    ProtocolCodeing();
public:
    int parseBasicInformation(QByteArray codeStr,FleetAgvBasicInfo &infoOut);
    int parseMessageInformation(QByteArray codeStr,QString &msgOut);
    int parseArmInformation(QByteArray codeStr,ArmInfo &infoOut);
    int isCommandReplyOk(QByteArray codeStr);

};

#endif // PROTOCOLCODEING_H
